package com.xtxb.app.rmq.api;

import com.xtxb.app.rmq.common.Topic;
import com.xtxb.app.rmq.conf.MQTopic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.ws.rs.*;
import java.util.*;

@Component
@Path("/topic")
public class TopicAPI extends AbtractAPI{

    @Autowired
    private MQTopic topics;

    @GET
    @Path("/list")
    @Produces("application/json")
    public Collection<Topic> getServers() {
        return topics.getTopics().values();
    }

    @POST
    @Path("/add")
    @Produces("application/json")
    @Consumes("application/json")
    public boolean addTopic(Topic topic){
        return topics.addTopic(topic);
    }

    @POST
    @Path("/delete")
    public boolean deleteTopic(@QueryParam("uuid") String uuid){
        return  topics.deleteTopic(uuid);
    }
}
